// pages/my/writeLogistics/writeLogistics.js
var app = getApp()
Page({
  data: {
    logisticsNo:'',
    logisticsCompany:'',
    returnId:''
  },
  onLoad: function (options) {
    let returnId = options.returnId
    this.setData({
      returnId
    })
  },
  getLogisticsNo(e){
    this.setData({
      logisticsNo:e.detail.value
    })
  },
  getLogisticCompany(e){
    this.setData({
      logisticsCompany:e.detail.value
    })
  },
  saveLogisticInfo(){
    let data = {
      returnsId:this.data.returnId,
      expressNo:this.data.logisticsNo,
      logistics_company:this.data.logisticsCompany
    }
    let that = this
    app.request('wx_app/after/sale/logistics/setting',data,'GET').then(res=>{
      if (res.code==1) {
        let page = getCurrentPages();
        let prev = page[page.length-2]
        prev.setData({
          logisticsCompany:that.data.logisticsCompany,
          logisticsNo:that.data.logisticsNo
        })
        wx.showToast({
          title:'保存成功'
        })
        setTimeout(function(){
          wx.navigateBack({
            success(){
              prev.onShow()
            }
          })
        },1000)
      }else{
        app.errorMsg(res.message)
      }
    })
  }
})